import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
    {
     title: '学/工号',
     align:"center",
     dataIndex: 'code'
    },
    {
     title: '姓名',
     align:"center",
     dataIndex: 'name'
    },
    {
     title: '设备名称',
     align:"center",
     dataIndex: 'deviceName'
    },
    {
      title: '下发状态',
      align:"center",
      dataIndex: 'distributeStatus',
      customRender: ({ text }) => {
        return render.renderDict(text, 'distributeStatus');
      },
     },
   {
    title: '创建日期',
    align:"center",
    dataIndex: 'createTime'
   },
   {
    title: '更新日期',
    align:"center",
    dataIndex: 'updateTime'
   },
 
];
//查询数据
export const searchFormSchema: FormSchema[] = [
     {
      label: "创建日期",
      field: "createTime",
      component: 'RangePicker',
      componentProps: {
          valueType: 'Date',
          showTime:true
      },
      //colProps: {span: 6},
	},
	{
      label: "学/工号",
      field: 'code',
      component: 'Input',
      //colProps: {span: 6},
 	},
  {
      label: "姓名",
      field: 'name',
      component: 'JInput',
      //colProps: {span: 6},
  },
	{
      label: "下发状态",
      field: 'distributeStatus',
      component: 'JDictSelectTag',
      componentProps:{
        dictCode:"distributeStatus",
      }
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '授权类型',
    field: 'dataType',
    component: 'RadioButtonGroup',
    defaultValue: '1',
    componentProps: {
      options: [
        { label: '部门', value: '1' },
        { label: '按人员', value: '2' },
      ],
    },
  },
  {
    label: '人员',
    field: 'personIds',
    component: 'JSelectPerson',
    componentProps: {
      labelKey: 'name',
    },
    // dynamicDisabled: ({ values }) => {
    //   return values.dataType==2;
    // },
    show: ({values})=>{
      return values.dataType==2;
    }
  },
  {
    label: '部门',
    field: 'departmentId',
    component: 'JSelectDept',
    componentProps: {
      multiple: false
      // labelKey: 'name',
    },
    // dynamicDisabled: ({ values }) => {
    //   return values.dataType==1;
    // },
    show: ({values})=>{
      return values.dataType==1;
    }
  },
  {
    label: '设备',
    field: 'deviceIdList',
    component: 'JSelectAttendanceDev',
    // slot: 'JSelectAttendanceDev',
    componentProps: {
      labelKey: 'deviceName',
    },
    // dynamicDisabled: ({ values }) => {
    //   return values.dataType==1;
    // },
    
  },
  {
    label: '删除',
    field: 'defFlag',
    component: 'Input',
    show:false,
    defaultValue:'0'
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  createBy: {title: '创建人',order: 0,view: 'text', type: 'string',},
  createTime: {title: '创建日期',order: 1,view: 'datetime', type: 'string',},
  updateBy: {title: '更新人',order: 2,view: 'text', type: 'string',},
  updateTime: {title: '更新日期',order: 3,view: 'datetime', type: 'string',},
  personId: {title: '人员id',order: 4,view: 'text', type: 'string',},
  distributeStatus: {title: '下发状态',order: 5,view: 'list', type: 'string',},
  defFlag: {title: '删除',order: 6,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
